var arr = [1, 2, 1, 4, 5, 5, 6, 6, 6, 6, 10, 12, 12, 18, 4];
// for(let i=0;i>=0;i--){
//     let index=arr.indexOf(arr[i]);
//     if(index>0&&index<i){

//     }
// }

function remove(arr) {
    for (let i = 0; i < arr.length; i++) {
        let index = arr.indexOf(arr[i], i + 1);
        if (index > 0) {
            arr[index] = arr[arr.length - 1];
            arr.length = arr.length - 1;
            i--;
        }
    }
    return arr;
}
var a = remove(arr);
console.log(a);
for (item of arr) {
    console.log(item);
}

var arr = [1, 2, 1, 4, 5, 5, 6, 6, 6, 6, 10, 12, 12, 18, 4];
var set = new Set(arr);
arr = []
for (let item of set) {
    arr.push(item);
}
console.log(arr);

for(let i=1;i<=3;i++){
    setTimeout(() => {
        console.log(i);
    }, 0);
}
